# -*- coding: utf-8 -*-
# __author__ = 'xxx'
# env: python 3.9.2 kubernetes  22.6.0
# fuction: 获取名空间对象

from  kubernetes import client,config
import yaml

def getapiclient():

    # 字典形式的 config
    configdirct=""
    config.load_kube_config_from_dict(configdirct)

    return  client;


def deploypod():
    getclient = getapiclient()

    # namsspace body 需要自己构建
    namespacebody = {

        "metadata": {

            "labels": {
                "kubernetes.io/metadata.name": "second"
            },
            "name": "second"
        }
    }


    #创建命名空间
    print(getclient.CoreV1Api().create_namespace(body=namespacebody))

    #删除 命名空间
    #print(getclient.CoreV1Api().delete_namespace(name="second"))

deploypod()

